import React, { Component } from 'react';
import Taro from '@tarojs/taro';
import {View} from '@tarojs/components'
import {h5Wx} from "../../utils/h5.service";
import GzhAuth from "../../components/gzh-auth/gzh-auth"
import {vcmonitor} from "../../utils/tools";

export default class CheckTicket extends Component {
  state: {
    accountNumber: string;
    bssid:string;
    password: string;
  } = {
    accountNumber: 'xiuxianhuzhao_5.0',//Wi-Fi 的SSID，即账号
    bssid: '9c:3d:cf:3d:f7:01',//Wi-Fi 的ISSID
    password: '',//Wi-Fi 的密码
  }
  page = 1
  limite = 20
  async UNSAFE_componentWillMount() {
    if(process.env.TARO_ENV==='h5'){
      const html = document.createElement("iframe");
      html.style.width = "100%";
      html.style.height = "100vh";
      const btn = document.getElementById("map");
      //console.log(btn)
      setTimeout(()=>{
        document.querySelector('.wifi-root').appendChild(html);
        html.src="https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=4IDBZ-YHFW4-MZ2UR-DM3ON-G72VS-FNFND&referer=ivcheng"
      },1000)
      window.addEventListener('message', function(event) {
        // 接收位置信息，用户选择确认位置点后选点组件会触发该事件，回传用户的位置信息
        var loc = event.data;
        if (loc && loc.module == 'locationPicker') {//防止其他应用也会向该页面post信息，需判断module是否为'locationPicker'
          //console.log('location', loc);
          Taro.setStorageSync('location', loc)
          Taro.navigateBack({
            delta: 1
          })
        }
      }, false);
      await h5Wx.getConfig()
    }
    if(process.env.TARO_ENV==="weapp"){
      Taro.hideShareMenu()
    }
  }
  async componentDidShow(){
      vcmonitor(this);
      Taro.onGetWifiList(result => {
        //console.log(result)
      })
  }



  render(){
    const {  } = this.state
    return (
      <View id={'map'} className="wifi-root">
        <GzhAuth />
      </View>
    )
  }
}
